#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include "service.h"
#include "utils.h"
#include "crc.h"

osEventFlagsId_t service_EvtID;
osThreadAttr_t service_Attr;

int service_ReadUartLength;
int service_UartLength;

uint8_t service_uartData[300];
uint8_t * service_uartDataPtr;

uint8_t service_sendUartData[100];
uint8_t * service_sendUartDataPtr;

void Service_sendOSEvent(void){
    osEventFlagsSet(service_EvtID, SERVICE_FLAGS_MSK1);
    osThreadYield();
}

// 业务处理线程
static void * service_Task(const char *arg){
    (void)arg;

    mm_LogPrint("[HMNetDTU]NetDTU service Task start....\r\n");

    return NULL;
}

void service_init(void){
    service_Attr.name = "service_Task";
    service_Attr.attr_bits = 0U;
    service_Attr.cb_mem = NULL;
    service_Attr.cb_size = 0U;
    service_Attr.stack_mem = NULL;
    service_Attr.stack_size = 1024 * 20;
    service_Attr.priority = 25;


    service_uartDataPtr = service_uartData;
    service_sendUartDataPtr = service_sendUartData;

    if (osThreadNew((osThreadFunc_t)service_Task, NULL, &service_Attr) == NULL) {
        mm_LogPrint("[HMNetDTU] Falied to create service_Task!\n");
    }
    service_ReadUartLength = 0;
    service_EvtID = osEventFlagsNew(NULL);

    service_init();
}